home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 39
/
Amiga Format CD39 (1999-04-13)(Future Publishing)(GB)[!][issue 1999-05].iso
/
-websites-
/
ppcrulez
/
files
/
ramlibpatch.lha
/
RamLibPatch
/
RamLibPatch.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-07-15
|
2KB
|
92 lines
/*
** $VER: RamLibPatch 1.1 (15.7.97)
**
** Patches the "ramlib" process to use a bigger stack
**
** (C) Copyright 1998 Andreas R. Kleinert
** All Rights Reserved.
*/
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/tasks.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char ver_text [] = "\0$VER: RamLibPatch 1.1 (15.7.98)";
#ifdef __SASC
extern BPTR _Backstdout;
extern struct WBStartup *WBenchMsg;
long __stack = 4096;
char *__procname = "RamLibPatch";
long __priority = 1;
long __BackGroundIO = 1;
void __regargs __chkabort(void) { }
void __regargs _CXBRK(void) { }
#endif /* __SASC */
#define STACKSIZE 16384
/* NOTE: This is NOT a good example for stack swapping,
since the OLD stack's buffer _NEVER_ will
be delocated. However, there is not other
way to achieve a larger stack for RamLib,
and since RamLib never will end, this perhaps
isn't a problem...
*/
void main(long argc, char **argv)
{
struct Task *we;
UBYTE *msg;
we = FindTask("ramlib");
if(we)
{
Forbid();
if( (ULONG) we->tc_SPUpper - (ULONG) we->tc_SPLower < STACKSIZE)
{
UBYTE *lower, *upper, *pointer;
ULONG inuse;
lower = (UBYTE *) AllocVec(16384, MEMF_PUBLIC);
upper = (UBYTE *) (STACKSIZE + (UBYTE *) lower);
inuse = (ULONG) we->tc_SPUpper - (ULONG) we->tc_SPReg;
pointer = ((UBYTE *) upper) - inuse;
CopyMem(we->tc_SPReg, pointer, inuse);
we->tc_SPReg = (APTR) pointer;
we->tc_SPLower = (APTR) lower;;
we->tc_SPUpper = (APTR) upper;
msg = "Patch done!\n";
}else msg = "Already patched.\n";
Permit();
}else msg = "Wrong AmigaOS version.\n";
if(_Backstdout) Write(_Backstdout, msg, strlen(msg));
exit(0);
}